{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "读取jass文件:war3map.j成功，文件大小:3616919byte\n"
     ]
    }
   ],
   "source": [
    "# 用来打开并读取jass文件\n",
    "import json\n",
    "\n",
    "FILE_NAME = \"war3map.j\"\n",
    "\n",
    "F = open(FILE_NAME, \"r\")\n",
    "Content = F.read()\n",
    "\n",
    "print \"读取jass文件:%s成功，文件大小:%dbyte\" % (FILE_NAME, len(Content))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#coding:utf-8\n",
    "# 建立基本分析要素——代码块（所有元素的始祖）\n",
    "class CodeBlock:\n",
    "    _rawcode = \"\"\n",
    "    _blocks = []\n",
    "    _analyzed = False\n",
    "    def setcode(self, code):\n",
    "        self._rawcode = code\n",
    "\n",
    "# =========五大基本代码块(原始块)===========\n",
    "# 控制块\n",
    "class ControlBlock(CodeBlock):\n",
    "# 变量块\n",
    "    pass\n",
    "class VariableBlock(CodeBlock):\n",
    "    pass\n",
    "# 函数块\n",
    "class FunctionBlock(CodeBlock):\n",
    "    pass\n",
    "# 执行块\n",
    "class ExecutionBlock(CodeBlock):\n",
    "    pass\n",
    "# 类型块\n",
    "class TypeBlock(CodeBlock):\n",
    "    \n",
    "    pass \n",
    "\n",
    "# ===========控制衍生代码块============\n",
    "class IfBlock(ControlBlock):\n",
    "    pass\n",
    "\n",
    "class LoopBlock(ControlBlock):\n",
    "    pass\n",
    "\n",
    "# ===========变量衍生代码块============\n",
    "class LocalBlock(VariableBlock):\n",
    "    _local_vals = {} #\n",
    "    pass\n",
    "\n",
    "class GlobalBlock(VariableBlock):\n",
    "    _global_vals = [] # (\"name\", \"type\", value(often directly gotten))\n",
    "    pass\n",
    "\n",
    "# ===========函数衍生代码块============\n",
    "class DeclearBlock(FunctionBlock):\n",
    "    pass\n",
    "\n",
    "class DefinitionBlock(FunctionBlock):\n",
    "    # 函数的定义方式是 :\n",
    "    # function XX takes YY t1, ZZ t2, ... returns MMM tm\n",
    "    # endfunction\n",
    "    _take_list = [] # [(\"name\", \"type\"), ....]\n",
    "    _return_list = [] # [(\"name\", \"type\"), ....]\n",
    "    pass\n",
    "\n",
    "# ===========执行衍生代码块============\n",
    "class CalculationBlock():\n",
    "    pass\n",
    "\n",
    "class CallBlock():\n",
    "    pass\n",
    "\n",
    "class ReturnBlock():\n",
    "    pass\n",
    "\n",
    "class AssignBlock():\n",
    "    pass\n",
    "\n",
    "# ===========类型衍生代码块============\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'FILE_NAME' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-2-472cf83506c7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      6\u001b[0m \u001b[0;31m# 这个版本是暂时的，只能用来获取函数项目，架构什么的根本没有\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      7\u001b[0m \u001b[0;31m# 而且假设.j文件完美无缺\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mF1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mFILE_NAME\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"r\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      9\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mContentSpliter_0\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcontent\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     10\u001b[0m     \u001b[0mstatus_array\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m\"unknown\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"parsingFunction\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'FILE_NAME' is not defined"
     ]
    }
   ],
   "source": [
    "#分离所有全局变量以及函数体\n",
    "\n",
    "# 全局变量\n",
    "# 函数\n",
    "\n",
    "# 这个版本是暂时的，只能用来获取函数项目，架构什么的根本没有\n",
    "# 而且假设.j文件完美无缺\n",
    "F1 = open(FILE_NAME, \"r\")\n",
    "def ContentSpliter_0(content):\n",
    "    status_array = [\"unknown\", \"parsingFunction\"]\n",
    "    status = \"unknown\"\n",
    "    \n",
    "    Function_Start = \"function\"\n",
    "    Function_End = \"endfuction\"\n",
    "    \n",
    "    Functions = []\n",
    "    Memory = []\n",
    "    FunctionName = \"\"\n",
    "        \n",
    "    line = F1.readline()\n",
    "    FunctionCnt = -1\n",
    "    while line:\n",
    "        if status == \"parsingFunction\":\n",
    "            if line.index(Function_End) < 0:\n",
    "                Memory.append(line)\n",
    "            else:\n",
    "                Memory.append(line)\n",
    "                Functions.append((FuntionName, \"\\n\".join(Memory)))\n",
    "                Memory = []\n",
    "                FunctionName = \"\"\n",
    "                status = \"unknown\"\n",
    "                \n",
    "        elif status == \"unknown\":\n",
    "            if line.index(Function_Start) < 0:\n",
    "                pass\n",
    "            else:\n",
    "                status = \"parsingFunction\"\n",
    "                FunctionCnt += 1\n",
    "                FunctionName = \"%d\" % FunctionCnt\n",
    "                Memory.append(line)\n",
    "        else:\n",
    "            pass\n",
    "        line = F1.readline()\n",
    "                \n",
    "    F1.close()\n",
    "    print Functions\n",
    "    return Functions\n",
    "            \n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 建立函数自身的运行树，分析函数之间的调用关系"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 分离Triggger相关的函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import json\n",
    "Result = json.loads(open(\"func_invoke.json\", \"r\").read())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "l = []\n",
    "for x in Result.keys():\n",
    "    l.append((x,len(Result[x])))\n",
    "\n",
    "def comp(A, B):\n",
    "    return A[1] > B[1]\n",
    "\n",
    "l = sorted(l, cmp=lambda x,y:cmp(x[1],y[1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "basefunc = [x for x in l if x[1] == 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from matplotlib import mlab\n",
    "from matplotlib import rcParams\n",
    "\n",
    "d = [x[1] for x in l]\n",
    "plt.hist(d, 500)\n",
    "plt.xlabel(\"Nums of called funcs\")\n",
    "plt.ylabel(\"Nums of these functions\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "24297\n"
     ]
    }
   ],
   "source": [
    "ss = sum([x[1] for x in l])\n",
    "print ss"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#输出dot文件\n",
    "F = open(\"graphviz.dot\", \"w\")\n",
    "F.write(\"digraph jass_imba{\\n\")\n",
    "F.write(\"\\n\")\n",
    "for R in Result.keys():\n",
    "    F.write(\"%s;\\n\" % R)\n",
    "\n",
    "F.write(\"\\n\")\n",
    "for R in Result.keys():\n",
    "    for P in Result[R]:\n",
    "        F.write(\"%s -> %s;\\n\" % (P, R))\n",
    "\n",
    "F.write(\"\\n}\")\n",
    "F.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "# 使用numpy.matrix进行分析\n",
    "IndexList = []\n",
    "OuterFuncList = []\n",
    "for i in l:\n",
    "    IndexList.append(i[0])\n",
    "for z in Result.keys():\n",
    "    for j in Result[z]:\n",
    "        if j not in IndexList:\n",
    "            OuterFuncList.append(j)\n",
    "print OuterFuncList\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set([u'J2B'])\n",
      "set([u'AGD'])\n",
      "set([u'AGC'])\n",
      "set([u'AGB'])\n",
      "set([u'DZB'])\n",
      "set([u'SZD'])\n",
      "set([u'WLB'])\n",
      "set([u'ZQE'])\n",
      "set([u'B2B'])\n",
      "set([u'JWG'])\n",
      "set([u'S9C'])\n",
      "set([u'Y1A'])\n",
      "set([u'BGH'])\n",
      "set([u'BWB'])\n",
      "set([u'EXNetRecv'])\n",
      "set([u'SPC'])\n",
      "set([u'UAF'])\n",
      "set([u'WRB'])\n",
      "set([u'MJB'])\n",
      "set([u'WRA'])\n",
      "set([u'RYB'])\n",
      "set([u'XPA'])\n",
      "set([u'VAA'])\n",
      "set([u'VAD'])\n",
      "set([u'IXE'])\n",
      "set([u'GIF'])\n",
      "set([u'DJB'])\n",
      "set([u'GIB'])\n",
      "set([u'W6A'])\n",
      "set([u'BYB'])\n",
      "set([u'AHC'])\n",
      "set([u'SNE'])\n",
      "set([u'Z6B'])\n",
      "set([u'Z6A'])\n",
      "set([u'R0C'])\n",
      "set([u'WUA'])\n",
      "set([u'XYC'])\n",
      "set([u'G2C'])\n",
      "set([u'WUE'])\n",
      "set([u'F6F'])\n",
      "set([u'H0D'])\n",
      "set([u'FFB'])\n",
      "set([u'GUC'])\n",
      "set([u'ALE'])\n",
      "set([u'CMG'])\n",
      "set([u'DTB'])\n",
      "set([u'EXNetSend'])\n",
      "set([u'D8B'])\n",
      "set([u'GCD'])\n",
      "set([u'EXNetSetString'])\n",
      "set([u'VLA'])\n",
      "set([u'IUC'])\n",
      "set([u'GDE'])\n",
      "set([u'V7A'])\n",
      "set([u'C4F'])\n",
      "set([u'C4B'])\n",
      "set([u'TTC'])\n",
      "set([u'UVA'])\n",
      "set([u'UVC'])\n",
      "set([u'UVE'])\n",
      "set([u'P1B'])\n",
      "set([u'P1C'])\n",
      "set([u'ZVB'])\n",
      "set([u'KPC'])\n",
      "set([u'IGC'])\n",
      "set([u'KPE'])\n",
      "set([u'UPA'])\n",
      "set([u'DSB'])\n",
      "set([u'DSC'])\n",
      "set([u'BLB'])\n",
      "set([u'TJA'])\n",
      "set([u'I2C'])\n",
      "set([u'InitCustomTeams'])\n",
      "set([u'UHC'])\n",
      "set([u'B9B'])\n",
      "set([u'R9C'])\n",
      "set([u'WQB'])\n",
      "set([u'X4C'])\n",
      "set([u'N9B'])\n",
      "set([u'INF'])\n",
      "set([u'LZE'])\n",
      "set([u'HLB'])\n",
      "set([u'KKC'])\n",
      "set([u'INC'])\n",
      "set([u'VBA'])\n",
      "set([u'VBD'])\n",
      "set([u'DOB'])\n",
      "set([u'DOC'])\n",
      "set([u'GLG'])\n",
      "set([u'O2B'])\n",
      "set([u'W5A'])\n",
      "set([u'O1B'])\n",
      "set([u'AKB'])\n",
      "set([u'SME'])\n",
      "set([u'AKD'])\n",
      "set([u'ZZB'])\n",
      "set([u'WHB'])\n",
      "set([u'G1G'])\n",
      "set([u'OUB'])\n",
      "set([u'G1C'])\n",
      "set([u'FCB'])\n",
      "set([u'E2B'])\n",
      "set([u'Y5A'])\n",
      "set([u'J7B'])\n",
      "set([u'BSG'])\n",
      "set([u'BSB'])\n",
      "set([u'YIE'])\n",
      "set([u'V4A'])\n",
      "set([])\n",
      "set([u'AUB'])\n",
      "set([u'AUH'])\n",
      "set([u'U9A'])\n",
      "set([u'D5D'])\n",
      "set([u'XTC'])\n",
      "set([u'Q6B'])\n",
      "set([u'XTA'])\n",
      "set([u'VEA'])\n",
      "set([u'M6F'])\n",
      "set([u'VOA'])\n",
      "set([u'EDB'])\n",
      "set([u'X7C'])\n",
      "set([u'PUD'])\n",
      "set([u'PUG'])\n",
      "set([u'T3B'])\n",
      "set([u'T3C'])\n",
      "set([u'T3A'])\n",
      "set([u'QUC'])\n",
      "set([u'Z2B'])\n",
      "set([u'Z2A'])\n",
      "set([u'LMB'])\n",
      "set([u'ORB'])\n",
      "set([u'JJB'])\n",
      "set([u'WQA'])\n",
      "set([u'MMB'])\n",
      "set([u'XHA'])\n",
      "set([u'XHE'])\n",
      "set([u'S7D'])\n",
      "set([u'BAB'])\n",
      "set([u'DPB'])\n",
      "set([u'A0B'])\n",
      "set([u'CAB'])\n",
      "set([u'UKB'])\n",
      "set([u'O3B'])\n",
      "set([u'NHB'])\n",
      "set([u'X1A'])\n",
      "set([u'X1C'])\n",
      "set([u'OYB'])\n",
      "set([u'Y0A'])\n",
      "set([u'VPA'])\n",
      "set([u'IIC'])\n",
      "set([u'IXC'])\n",
      "set([u'DYB'])\n",
      "set([u'W8A'])\n",
      "set([u'ABC'])\n",
      "set([u'SOC'])\n",
      "set([u'P5B'])\n",
      "set([u'YPA'])\n",
      "set([u'V0A'])\n",
      "set([u'ZRA'])\n",
      "set([u'KTD'])\n",
      "set([u'HGB'])\n",
      "set([u'HGC'])\n",
      "set([u'N4G'])\n",
      "set([u'A9G'])\n",
      "set([u'A9F'])\n",
      "set([u'TFA'])\n",
      "set([u'TFC'])\n",
      "set([u'A9B'])\n",
      "set([u'K3G'])\n",
      "set([u'UDA'])\n",
      "set([u'EXNetGetInteger'])\n",
      "set([u'PNC'])\n",
      "set([u'PNB'])\n",
      "set([u'D3B'])\n",
      "set([u'VFD'])\n",
      "set([u'XQE'])\n",
      "set([u'VFA'])\n",
      "set([])\n",
      "set([u'DKB'])\n",
      "set([u'GHB'])\n",
      "set([u'OWB'])\n",
      "set([u'AOD'])\n",
      "set([u'AOB'])\n",
      "set([u'Z7A'])\n",
      "set([u'Z7B'])\n",
      "set([u'G3C'])\n",
      "set([u'WTA'])\n",
      "set([u'WTB'])\n",
      "set([u'XZC'])\n",
      "set([u'FGD'])\n",
      "set([u'W8E'])\n",
      "set([u'L0B'])\n",
      "set([u'URE'])\n",
      "set([u'CHB'])\n",
      "set([u'TPC'])\n",
      "set([u'CHE'])\n",
      "set([u'NEC'])\n",
      "set([u'PQC'])\n",
      "set([u'LPG'])\n",
      "set([u'JAE'])\n",
      "set([u'MRB'])\n",
      "set([u'KAC'])\n",
      "set([u'KAB'])\n",
      "set([u'C9B'])\n",
      "set([u'VIA'])\n",
      "set([u'ZQA'])\n",
      "set([u'DBB'])\n",
      "set([u'T8C'])\n",
      "set([u'DBF'])\n",
      "set([u'M5D'])\n",
      "set([u'UYE'])\n",
      "set([u'M5C'])\n",
      "set([u'APB'])\n",
      "set([u'B6F'])\n",
      "set([u'V3F'])\n",
      "set([u'P2C'])\n",
      "set([u'I4F'])\n",
      "set([u'YSB'])\n",
      "set([u'ZWB'])\n",
      "set([u'U8A'])\n",
      "set([u'I4C'])\n",
      "set([u'JTB'])\n",
      "set([u'IFB'])\n",
      "set([u'ZAA'])\n",
      "set([u'BMB'])\n",
      "set([u'A4B'])\n",
      "set([u'TKA'])\n",
      "set([u'UGA'])\n",
      "set([u'F1D'])\n",
      "set([u'PKB'])\n",
      "set([u'OJD'])\n",
      "set([u'NLB'])\n",
      "set([u'I3C'])\n",
      "set([u'Q3C'])\n",
      "set([u'DLB'])\n",
      "set([u'Q3F'])\n",
      "set([u'O4F'])\n",
      "set([u'SHC'])\n",
      "set([u'OBB'])\n",
      "set([u'P9C'])\n",
      "set([u'YTB'])\n",
      "set([u'OXB'])\n",
      "set([u'WOB'])\n",
      "set([u'XCB'])\n",
      "set([u'MGB'])\n",
      "set([u'G4C'])\n",
      "set([u'MGG'])\n",
      "set([u'E5D'])\n",
      "set([u'S7B'])\n",
      "set([u'KXD'])\n",
      "set([u'GZC'])\n",
      "set([u'BTE'])\n",
      "set([u'J8B'])\n",
      "set([u'BTB'])\n",
      "set([u'CZB'])\n",
      "set([u'F8C'])\n",
      "set([u'M1B'])\n",
      "set([u'ATB'])\n",
      "set([u'R4C'])\n",
      "set([u'RRC'])\n",
      "set([u'GBD'])\n",
      "set([u'HGF'])\n",
      "set([u'XUA'])\n",
      "set([u'MUC'])\n",
      "set([u'XUC'])\n",
      "set([u'ISC'])\n",
      "set([u'VJB'])\n",
      "set([u'VJA'])\n",
      "set([u'ISF'])\n",
      "set([u'DGB'])\n",
      "set([u'ASB'])\n",
      "set([u'DGH'])\n",
      "set([u'Z3D'])\n",
      "set([u'RMC'])\n",
      "set([u'SEC'])\n",
      "set([u'FXC'])\n",
      "set([u'NUB'])\n",
      "set([u'WPA'])\n",
      "set([u'JKB'])\n",
      "set([u'QTC'])\n",
      "set([u'FRC'])\n",
      "set([u'IMC'])\n",
      "set([u'GTD'])\n",
      "set([u'DUB'])\n",
      "set([])\n",
      "set([u'BBB'])\n",
      "set([u'A3B'])\n",
      "set([u'TLA'])\n",
      "set([u'YAG'])\n",
      "set([u'ZEA'])\n",
      "set([u'ODD'])\n",
      "set([u'U1C'])\n",
      "set([u'ITE'])\n",
      "set([u'ITC'])\n",
      "set([u'HVG'])\n",
      "set([u'VMA'])\n",
      "set([u'RGC'])\n",
      "set([u'WPB'])\n",
      "set([u'TUB'])\n",
      "set([u'C7B'])\n",
      "set([u'UUA'])\n",
      "set([u'RSF'])\n",
      "set([u'UUC'])\n",
      "set([u'VTA'])\n",
      "set([u'BPB'])\n",
      "set([u'AAC'])\n",
      "set([u'SWG'])\n",
      "set([u'JYF'])\n",
      "set([u'P6C'])\n",
      "set([u'P6B'])\n",
      "set([u'WBB'])\n",
      "set([u'ZSB'])\n",
      "set([u'WBA'])\n",
      "set([u'EXNetGetString'])\n",
      "set([u'V1A'])\n",
      "set([u'N5B'])\n",
      "set([u'FYC'])\n",
      "set([u'GYC'])\n",
      "set([u'KWG'])\n",
      "set([u'A8B'])\n",
      "set([u'CYB'])\n",
      "set([u'RPC'])\n",
      "set([u'TGA'])\n",
      "set([u'CYE'])\n",
      "set([u'DTC'])\n",
      "set([])\n",
      "set([u'K2D'])\n",
      "set([u'MLB'])\n",
      "set([u'VCA'])\n",
      "set([u'IZC'])\n",
      "set([u'G9B'])\n",
      "set([u'DHB'])\n",
      "set([u'GOC'])\n",
      "set([u'W4A'])\n",
      "set([u'WNA'])\n",
      "set([u'CWE'])\n",
      "set([u'AJE'])\n",
      "set([u'U2A'])\n",
      "set([u'Z8B'])\n",
      "set([u'TLB'])\n",
      "set([u'OTB'])\n",
      "set([u'WKB'])\n",
      "set([u'V8A'])\n",
      "set([u'MCB'])\n",
      "set([u'XGA'])\n",
      "set([u'E1B'])\n",
      "set([u'GFF'])\n",
      "set([u'Y4A'])\n",
      "set([])\n",
      "set([u'CKG'])\n",
      "set([u'LFC'])\n",
      "set([u'TQA'])\n",
      "set([u'UQA'])\n",
      "set([u'UQC'])\n",
      "set([u'H6G'])\n",
      "set([u'YLF'])\n",
      "set([u'PAB'])\n",
      "set([u'YLC'])\n",
      "set([u'ZFC'])\n",
      "set([u'XJA'])\n",
      "set([u'AXH'])\n",
      "set([u'MQB'])\n",
      "set([u'IWC'])\n",
      "set([u'VNB'])\n",
      "set([u'VNA'])\n",
      "set([u'DCB'])\n",
      "set([u'C2B'])\n",
      "set([u'UXA'])\n",
      "set([u'GEG'])\n",
      "set([u'PZB'])\n",
      "set([u'I7G'])\n",
      "set([u'XIA'])\n",
      "set([u'ZXB'])\n",
      "set([u'XIE'])\n",
      "set([u'VXD'])\n",
      "set([u'VXA'])\n",
      "set([u'KNC'])\n",
      "set([u'HAF'])\n",
      "set([u'VFB'])\n",
      "set([u'M2D'])\n",
      "set([u'HBC'])\n",
      "set([u'DQB'])\n",
      "set([u'DQC'])\n",
      "set([u'A7G'])\n",
      "set([u'THE'])\n",
      "set([u'UJG'])\n",
      "set([u'EQE'])\n",
      "set([u'THA'])\n",
      "set([u'SYC'])\n",
      "set([u'GWC'])\n",
      "set([])\n",
      "set([u'QJC'])\n",
      "set([u'X2A'])\n",
      "set([u'ZAC'])\n",
      "set([u'X2C'])\n",
      "set([u'X2B'])\n",
      "set([u'HJC'])\n",
      "set([u'MZC'])\n",
      "set([u'VQA'])\n",
      "set([u'VQF'])\n",
      "set([u'DMB'])\n",
      "set([u'J0B'])\n",
      "set([u'CRB'])\n",
      "set([u'SKD'])\n",
      "set([u'AEB'])\n",
      "set([u'CCG'])\n",
      "set([u'JUB'])\n",
      "set([u'B0B'])\n",
      "set([u'B0G'])\n",
      "set([u'V5A'])\n",
      "set([u'PHD'])\n",
      "set([u'Y7G'])\n",
      "set([u'J9B'])\n",
      "set([u'BUB'])\n",
      "set([u'TCA'])\n",
      "set([u'QXB'])\n",
      "set([u'ZOB'])\n",
      "set([u'ZOF'])\n",
      "set([u'XRE'])\n",
      "set([u'JGB'])\n",
      "set([u'LJE'])\n",
      "set([u'VGA'])\n",
      "set([u'LJD'])\n",
      "set([u'FOE'])\n",
      "set([u'VAC'])\n",
      "set([u'DDC'])\n",
      "set([u'DDB'])\n",
      "set([u'JGG'])\n",
      "set([u'GKF'])\n",
      "set([u'AND'])\n",
      "set([u'TUC'])\n",
      "set([u'H8G'])\n",
      "set([u'T1A'])\n",
      "set([u'PSB'])\n",
      "set([u'QWD'])\n",
      "set([u'Z4A'])\n",
      "set([u'QWB'])\n",
      "set([u'NAF'])\n",
      "set([u'Z4B'])\n",
      "set([u'WWE'])\n",
      "set([u'JLD'])\n",
      "set([u'JLG'])\n",
      "set([u'LCC'])\n",
      "set([u'OPB'])\n",
      "set([u'WWB'])\n",
      "set([u'MOC'])\n",
      "set([u'MOB'])\n",
      "set([u'GWF'])\n",
      "set([u'ILC'])\n",
      "set([u'FSF'])\n",
      "set([u'VUA'])\n",
      "set([u'CGB'])\n",
      "set([u'DVB'])\n",
      "set([u'UMA'])\n",
      "set([u'OHB'])\n",
      "set([u'NJB'])\n",
      "set([u'I9G'])\n",
      "set([u'ZBC'])\n",
      "set([u'X3C'])\n",
      "set([u'XZG'])\n",
      "set([u'U0A'])\n",
      "set([u'IKC'])\n",
      "set([u'VRA'])\n",
      "set([u'VRF'])\n",
      "set([u'DDD'])\n",
      "set([u'C6B'])\n",
      "set([u'VOB'])\n",
      "set([u'TVC'])\n",
      "set([u'WIG'])\n",
      "set([u'YRA'])\n",
      "set([u'ZTA'])\n",
      "set([u'XMA'])\n",
      "set([u'WAA'])\n",
      "set([u'ZTB'])\n",
      "set([u'N6B'])\n",
      "set([u'HEC'])\n",
      "set([u'FZB'])\n",
      "set([u'IEC'])\n",
      "set([u'IED'])\n",
      "set([u'TJD'])\n",
      "set([u'CDB'])\n",
      "set([u'UFA'])\n",
      "set([u'TDA'])\n",
      "set([u'F6B'])\n",
      "set([u'D1C'])\n",
      "set([u'X6A'])\n",
      "set([u'X6C'])\n",
      "set([u'X6B'])\n",
      "set([u'I2D'])\n",
      "set([u'WSA'])\n",
      "set([u'EHE'])\n",
      "set([u'WSB'])\n",
      "set([u'WSE'])\n",
      "set([u'IYC'])\n",
      "set([u'FHD'])\n",
      "set([u'B4B'])\n",
      "set([u'DIB'])\n",
      "set([u'FHB'])\n",
      "set([u'C8B'])\n",
      "set([u'W7A'])\n",
      "set([u'UBF'])\n",
      "set([u'BFG'])\n",
      "set([u'BXB'])\n",
      "set([u'URA'])\n",
      "set([u'QRB'])\n",
      "set([u'Z9B'])\n",
      "set([u'Z9A'])\n",
      "set([u'VHA'])\n",
      "set([u'JQD'])\n",
      "set([u'WJB'])\n",
      "set([u'WJA'])\n",
      "set([u'XXC'])\n",
      "set([u'XXB'])\n",
      "set([u'XXA'])\n",
      "set([u'V9A'])\n",
      "set([u'LWD'])\n",
      "set([u'G3G'])\n",
      "set([u'Z4F'])\n",
      "set([u'EXNetSetInteger'])\n",
      "set([u'GAC'])\n",
      "set([u'NVB'])\n",
      "set([u'U4A'])\n",
      "set([u'UTA'])\n",
      "set([u'M0B'])\n",
      "set([u'GYF'])\n",
      "set([u'YOE'])\n",
      "set([u'ZKC'])\n",
      "set([u'VKA'])\n",
      "set([u'IRC'])\n",
      "set([u'C1B'])\n",
      "set([u'VWA'])\n",
      "set([u'M7B'])\n",
      "set([u'ARB'])\n",
      "set([u'PWB'])\n",
      "set([u'M7F'])\n",
      "set([u'ARH'])\n",
      "set([u'Z0B'])\n",
      "set([u'WDA'])\n",
      "set([u'ZYB'])\n",
      "set([u'XJC'])\n",
      "set([u'C0D'])\n",
      "set([u'FWB'])\n",
      "set([u'N3G'])\n",
      "set([u'A6H'])\n",
      "set([u'BOB'])\n",
      "set([u'DRB'])\n",
      "set([u'TIA'])\n",
      "set([u'CCB'])\n",
      "set([u'SXE'])\n",
      "set([u'UIG'])\n",
      "set([u'R8C'])\n",
      "set([u'NNB'])\n",
      "set([u'D6C'])\n",
      "set([u'YDA'])\n",
      "set([u'FJC'])\n",
      "set([u'MIB'])\n",
      "set([u'B5E'])\n",
      "set([u'IOC'])\n",
      "set([u'MFG'])\n",
      "set([u'VVA'])\n",
      "set([u'UCA'])\n",
      "set([u'IPC'])\n",
      "set([u'CQB'])\n",
      "set([u'RXB'])\n",
      "set([u'NXE'])\n",
      "set([u'NXD'])\n",
      "set([u'B5H'])\n",
      "set([u'P7B'])\n",
      "set([u'JVB'])\n",
      "set([u'WMA'])\n",
      "set([u'ZPE'])\n",
      "set([u'ZPD'])\n",
      "set([u'V6A'])\n",
      "set([u'ZPF'])\n",
      "set([u'KVD'])\n",
      "set([u'GXC'])\n",
      "set([u'Y2A'])\n",
      "set([u'E7F'])\n",
      "set([u'C3E'])\n",
      "set([u'CXB'])\n",
      "set([u'RQC'])\n",
      "set([u'SQC'])\n",
      "set([u'BZB'])\n",
      "set([u'YJA'])\n",
      "set([u'VDA'])\n",
      "set([u'XSA'])\n",
      "set([u'VDF'])\n",
      "set([u'EEE'])\n",
      "set([u'DEB'])\n",
      "set([u'C3B'])\n",
      "set([u'GJB'])\n",
      "set([u'W3A'])\n",
      "set([u'W3E'])\n",
      "set([u'T2C'])\n",
      "set([u'AMB'])\n",
      "set([u'AME'])\n",
      "set([u'PTB'])\n",
      "set([u'Z5B'])\n",
      "set([u'B8H'])\n",
      "set([u'NWB'])\n",
      "set([u'MNB'])\n",
      "set([u'WVE'])\n",
      "set([u'BDB'])\n",
      "set([u'EXNetCreate'])\n",
      "set([u'PBB'])\n",
      "set([])\n",
      "set([u'MPB'])\n",
      "set([u'MPC'])\n",
      "set([u'U3A'])\n",
      "set([u'IVC'])\n",
      "set([u'I9B'])\n",
      "set([u'MDB'])\n",
      "set([u'AVH'])\n",
      "set([u'C5B'])\n",
      "set([u'W8B'])\n",
      "set([u'UWA'])\n",
      "set([u'M3B'])\n",
      "set([u'UWE'])\n",
      "set([u'AVC'])\n",
      "set([u'ACC'])\n",
      "set([u'JEE'])\n",
      "set([u'ACF'])\n",
      "set([u'XFE'])\n",
      "set([u'NEB'])\n",
      "set([u'P4B'])\n",
      "set([u'YQB'])\n",
      "set([u'ZUB'])\n",
      "set([u'V3A'])\n",
      "set([u'XND'])\n",
      "set([u'N7B'])\n",
      "set([u'KUD'])\n",
      "set([u'HFF'])\n",
      "set([u'NGB'])\n",
      "set([u'TEA'])\n",
      "set([u'RRD'])\n",
      "set([u'UEA'])\n",
      "set([u'CGG'])\n",
      "set([u'I4G'])\n",
      "set([u'YXB'])\n",
      "set([u'YXA'])\n",
      "set([u'X7B'])\n",
      "set([u'NBF'])\n",
      "set([u'I1C'])\n",
      "set([u'X7A'])\n",
      "set([u'DNB'])\n",
      "set([u'GMB'])\n",
      "set([u'J1B'])\n",
      "set([u'RDE'])\n",
      "set([u'ADB'])\n",
      "set([u'ADC'])\n",
      "set([u'B1F'])\n",
      "set([u'MTC'])\n",
      "set([u'B1E'])\n",
      "set([u'OZB'])\n",
      "set([u'WIB'])\n",
      "set([u'MEB'])\n",
      "set([u'E3G'])\n",
      "set([u'X0C'])\n",
      "set([u'Y6F'])\n",
      "set([u'Y6A'])\n",
      "set([u'KZD'])\n",
      "set([u'J6B'])\n",
      "set([u'BRC'])\n",
      "set([u'BRB'])\n",
      "set([u'TWB'])\n",
      "set([u'CIB'])\n",
      "set([u'USE'])\n",
      "set([u'CIE'])\n",
      "set([u'YNE'])\n",
      "set([u'AZD'])\n",
      "set([u'AZF'])\n",
      "set([u'X9A'])\n",
      "set([u'X9B'])\n",
      "set([u'X9E'])\n",
      "set([u'XWB'])\n",
      "set([u'MSB'])\n",
      "set([u'IQC'])\n",
      "set([u'DAB'])\n",
      "set([u'UZE'])\n",
      "set([u'C0B'])\n",
      "set([u'TXC'])\n",
      "set([u'UZA'])\n",
      "set([u'TXA'])\n",
      "set([u'RKD'])\n",
      "set([u'M6B'])\n",
      "set([])\n",
      "set([u'PXB'])\n",
      "set([u'Z1B'])\n",
      "set([u'FPC'])\n",
      "set([u'FPB'])\n",
      "set([])\n",
      "set([u'GVC'])\n",
      "set([u'TNA'])\n",
      "set([u'TNB'])\n",
      "set([u'ULA'])\n",
      "set([u'ULD'])\n",
      "set([u'NKC'])\n",
      "set([u'EXNetGetCount'])\n",
      "set([u'I8B'])\n",
      "set([u'X0A'])\n",
      "set([])\n",
      "set([u'VSA'])\n",
      "set([u'DFB'])\n",
      "set([u'HHF'])\n"
     ]
    }
   ],
   "source": [
    "CycleFirstResult = []\n",
    "FirstZeros = {}\n",
    "class FuncStatWrapper:\n",
    "    def __init__(self, name):\n",
    "        self.callers = set()\n",
    "        self.name = name\n",
    "        \n",
    "for i in l:\n",
    "    if i[1]==0:\n",
    "        FirstZeros[i[0]] = FuncStatWrapper(i[0])\n",
    "\n",
    "for i in Result.keys():\n",
    "    if i not in FirstZeros:\n",
    "        for j in Result[i]:\n",
    "            if j in FirstZeros.keys():\n",
    "                FirstZeros[j].callers.add(j)\n",
    "\n",
    "for i in FirstZeros:\n",
    "    print FirstZeros[i].callers\n",
    "    \n",
    "                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[u'AUC', u'GHF', u'ShowMinimapIcon', u'kill1hero', u'TestUnitOut', u'HasBuildTimerOfAKSS', u'YCE', u'RKB', u'UnitScaleNum', u'I8A']\n",
      "[]\n"
     ]
    }
   ],
   "source": [
    "NoUseFunctions = []\n",
    "MultipleCallerFunctions = []\n",
    "for i in FirstZeros:\n",
    "    le = len(FirstZeros[i].callers)\n",
    "    if le == 0:\n",
    "        NoUseFunctions.append(i)\n",
    "    elif le > 1:\n",
    "        MultipleCallerFunctions.append(i)\n",
    "    else:\n",
    "        pass\n",
    "print NoUseFunctions\n",
    "print MultipleCallerFunctions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "704\n"
     ]
    }
   ],
   "source": [
    "print len(FirstZeros)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class FuncTreeNode:\n",
    "    def __init__(self, node, childs=None)\n",
    "        self.name = node\n",
    "        self.childs = childs # childs is other node list\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4125\n"
     ]
    }
   ],
   "source": [
    "Result_1 = {}\n",
    "for j in Result:\n",
    "    if j not in FirstZeros:\n",
    "        arr = [x for x in Result[j] if x not in FirstZeros]\n",
    "        Result_1[j] = arr\n",
    "print len(Result_1.keys())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set([u'CPE'])\n",
      "set([u'SIC'])\n",
      "set([u'XBE'])\n",
      "set([u'B2E'])\n",
      "set([u'P8F'])\n",
      "set([u'G5F'])\n",
      "set([u'TAC'])\n",
      "set([u'UAA'])\n",
      "set([u'UAB'])\n",
      "set([u'MJG'])\n",
      "set([u'LHC'])\n",
      "set([u'NVC'])\n",
      "set([u'FIC'])\n",
      "set([u'B8B'])\n",
      "set([u'AHD'])\n",
      "set([u'LAB'])\n",
      "set([u'OVB'])\n",
      "set([u'XYA'])\n",
      "set([u'MAB'])\n",
      "set([u'G2B'])\n",
      "set([u'PCB'])\n",
      "set([u'JWB'])\n",
      "set([u'KBB'])\n",
      "set([u'UPF'])\n",
      "set([u'H1B'])\n",
      "set([u'M2B'])\n",
      "set([u'YYC'])\n",
      "set([u'WGB'])\n",
      "set([u'I5C'])\n",
      "set([u'ZVE'])\n",
      "set([u'Y8A'])\n",
      "set([u'RWB'])\n",
      "set([u'R9B'])\n",
      "set([u'NOC'])\n",
      "set([u'HLG'])\n",
      "set([u'MXE'])\n",
      "set([u'VWB'])\n",
      "set([u'FJB'])\n",
      "set([u'GLE'])\n",
      "set([u'AKH'])\n",
      "set([u'CTC'])\n",
      "set([u'T4C'])\n",
      "set([u'T4A'])\n",
      "set([u'JSE'])\n",
      "set([u'JSC'])\n",
      "set([u'FCC'])\n",
      "set([u'JTC'])\n",
      "set([u'GQF'])\n",
      "set([u'BSC'])\n",
      "set([u'YIA'])\n",
      "set([u'R7F'])\n",
      "set([u'YIB'])\n",
      "set([u'ZMD'])\n",
      "set([u'JEC'])\n",
      "set([u'VEB'])\n",
      "set([u'W2D'])\n",
      "set([u'ALH'])\n",
      "set([u'W2A'])\n",
      "set([u'PUB'])\n",
      "set([u'QUE'])\n",
      "set([u'I0C'])\n",
      "set([u'FQC'])\n",
      "set([u'IBD'])\n",
      "set([u'ZXC'])\n",
      "set([u'FQE'])\n",
      "set([u'T6A'])\n",
      "set([u'HID'])\n",
      "set([u'YPB'])\n",
      "set([u'B7B'])\n",
      "set([u'JXB'])\n",
      "set([u'NZG'])\n",
      "set([u'N4B'])\n",
      "set([u'FXB'])\n",
      "set([u'E9B'])\n",
      "set([u'TFD'])\n",
      "set([u'K3B'])\n",
      "set([u'NCB'])\n",
      "set([u'ZNB'])\n",
      "set([u'JFC'])\n",
      "set([u'FNC'])\n",
      "set([u'W1A'])\n",
      "set([u'RAG'])\n",
      "set([u'T0C'])\n",
      "set([u'T0A'])\n",
      "set([u'OQB'])\n",
      "set([u'XZB'])\n",
      "set([u'FGB'])\n",
      "set([u'CHC'])\n",
      "set([u'TPB'])\n",
      "set([u'BFD'])\n",
      "set([u'HRE'])\n",
      "set([u'WZD'])\n",
      "set([u'LPD'])\n",
      "set([u'JAB'])\n",
      "set([u'JAC'])\n",
      "set([u'IPD'])\n",
      "set([u'TYA'])\n",
      "set([u'TYC'])\n",
      "set([u'UYC'])\n",
      "set([u'U8B'])\n",
      "set([u'SFE'])\n",
      "set([u'APF'])\n",
      "set([u'QYB'])\n",
      "set([u'FUB'])\n",
      "set([u'A4F'])\n",
      "set([u'CEF'])\n",
      "set([u'QOC'])\n",
      "set([u'D0B'])\n",
      "set([u'X5B'])\n",
      "set([u'HME'])\n",
      "set([u'HMB'])\n",
      "set([u'Q3E'])\n",
      "set([u'GCF'])\n",
      "set([u'T9A'])\n",
      "set([u'CSC'])\n",
      "set([u'JTE'])\n",
      "set([u'B3F'])\n",
      "set([u'B3B'])\n",
      "set([u'GZB'])\n",
      "set([u'BTC'])\n",
      "set([u'F8B'])\n",
      "set([u'YHA'])\n",
      "set([u'FDB'])\n",
      "set([u'JBC'])\n",
      "set([u'XUB'])\n",
      "set([u'IRB'])\n",
      "set([u'ISE'])\n",
      "set([u'DGC'])\n",
      "set([u'PVB'])\n",
      "set([u'QTB'])\n",
      "set([u'Z3B'])\n",
      "set([u'NUD'])\n",
      "set([u'LNC'])\n",
      "set([u'ASE'])\n",
      "set([u'FRE'])\n",
      "set([u'DUE'])\n",
      "set([u'EUC'])\n",
      "set([u'EUB'])\n",
      "set([u'A3H'])\n",
      "set([u'D2C'])\n",
      "set([u'D9B'])\n",
      "set([u'U1B'])\n",
      "set([u'HVE'])\n",
      "set([u'UUE'])\n",
      "set([u'H2B'])\n",
      "set([u'AAB'])\n",
      "set([])\n",
      "set([u'Q1F'])\n",
      "set([])\n",
      "set([u'E8B'])\n",
      "set([u'KWD'])\n",
      "set([u'Y3A'])\n",
      "set([u'K2B'])\n",
      "set([u'G9G'])\n",
      "set([u'LDC'])\n",
      "set([u'IZE'])\n",
      "set([u'DHH'])\n",
      "set([u'Q7C'])\n",
      "set([u'AJH'])\n",
      "set([u'T5A'])\n",
      "set([u'CWB'])\n",
      "set([u'QSC'])\n",
      "set([u'QSB'])\n",
      "set([u'QSE'])\n",
      "set([u'WKA'])\n",
      "set([u'LGC'])\n",
      "set([u'XGB'])\n",
      "set([u'GFB'])\n",
      "set([u'DZC'])\n",
      "set([u'UQE'])\n",
      "set([u'YLB'])\n",
      "set([u'PAF'])\n",
      "set([u'LQD'])\n",
      "set([u'HSG'])\n",
      "set([u'HSE'])\n",
      "set([u'C2C'])\n",
      "set([u'W9B'])\n",
      "set([u'W9A'])\n",
      "set([u'M4B'])\n",
      "set([u'AWD'])\n",
      "set([u'Wy'])\n",
      "set([u'ZXA'])\n",
      "set([u'WEA'])\n",
      "set([u'I7C'])\n",
      "set([u'GEE'])\n",
      "set([u'N2B'])\n",
      "set([u'FVC'])\n",
      "set([u'HAG'])\n",
      "set([u'THD'])\n",
      "set([u'BND'])\n",
      "set([u'F2B'])\n",
      "set([u'SYD'])\n",
      "set([u'YEA'])\n",
      "set([u'HJD'])\n",
      "set([u'VQB'])\n",
      "set([u'EMG'])\n",
      "set([u'Q2C'])\n",
      "set([u'DMD'])\n",
      "set([u'EMB'])\n",
      "set([u'CRG'])\n",
      "set([u'WNB'])\n",
      "set([u'MFB'])\n",
      "set([u'V5C'])\n",
      "set([u'uo'])\n",
      "set([u'E4D'])\n",
      "set([u'BUC'])\n",
      "set([u'YKB'])\n",
      "set([u'LJC'])\n",
      "set([u'XRA'])\n",
      "set([u'VGB'])\n",
      "set([u'RAB'])\n",
      "set([u'WWA'])\n",
      "set([u'JLB'])\n",
      "set([])\n",
      "set([u'ILG'])\n",
      "set([u'KMD'])\n",
      "set([u'UME'])\n",
      "set([u'NJC'])\n",
      "set([u'X3B'])\n",
      "set([u'I9C'])\n",
      "set([u'KDF'])\n",
      "set([u'LBD'])\n",
      "set([u'P3B'])\n",
      "set([u'YRB'])\n",
      "set([u'NDB'])\n",
      "set([u'WAB'])\n",
      "set([u'V2C'])\n",
      "set([u'UFB'])\n",
      "set([u'NMB'])\n",
      "set([u'D1B'])\n",
      "set([u'D4B'])\n",
      "set([u'HKE'])\n",
      "set([u'LOB'])\n",
      "set([u'IYB'])\n",
      "set([u'Q0C'])\n",
      "set([u'EIB'])\n",
      "set([u'C8E'])\n",
      "set([u'BXC'])\n",
      "set([u'CVB'])\n",
      "set([u'PPB'])\n",
      "set([u'Z9E'])\n",
      "set([u'QRE'])\n",
      "set([u'G3B'])\n",
      "set([u'FAB'])\n",
      "set([u'LCB'])\n",
      "set([u'XWA'])\n",
      "set([u'E0B'])\n",
      "set([u'X8A'])\n",
      "set([u'WXA'])\n",
      "set([u'JCC'])\n",
      "set([u'XVA'])\n",
      "set([u'HPB'])\n",
      "set([u'U7A'])\n",
      "set([u'XVB'])\n",
      "set([u'EBB'])\n",
      "set([u'C1E'])\n",
      "set([u'NAB'])\n",
      "set([u'OAB'])\n",
      "set([u'I6C'])\n",
      "set([u'N3B'])\n",
      "set([u'KQC'])\n",
      "set([u'VYA'])\n",
      "set([u'DRC'])\n",
      "set([u'A6G'])\n",
      "set([u'TIC'])\n",
      "set([u'R8B'])\n",
      "set([u'R8F'])\n",
      "set([u'LYD'])\n",
      "set([u'N8B'])\n",
      "set([u'HKB'])\n",
      "set([u'IOF'])\n",
      "set([u'KHF'])\n",
      "set([u'KHG'])\n",
      "set([u'CQG'])\n",
      "set([u'NXB'])\n",
      "set([u'B5B'])\n",
      "set([u'WMB'])\n",
      "set([u'ETB'])\n",
      "set([u'BVC'])\n",
      "set([u'YJE'])\n",
      "set([u'LKE'])\n",
      "set([u'JDC'])\n",
      "set([u'DEC'])\n",
      "set([u'EEB'])\n",
      "set([u'QVB'])\n",
      "set([u'T2F'])\n",
      "set([u'OSB'])\n",
      "set([u'EWC'])\n",
      "set([u'CJC'])\n",
      "set([u'UPC'])\n",
      "set([u'CJE'])\n",
      "set([u'R1G'])\n",
      "set([u'ZGC'])\n",
      "set([u'HTG'])\n",
      "set([u'IVE'])\n",
      "set([u'KCG'])\n",
      "set([u'ZBA'])\n",
      "set([u'LRF'])\n",
      "set([u'M3D'])\n",
      "set([u'ACB'])\n",
      "set([u'SUC'])\n",
      "set([u'ACD'])\n",
      "set([u'HFC'])\n",
      "set([u'HFD'])\n",
      "set([u'TEC'])\n",
      "set([u'PMB'])\n",
      "set([u'NBB'])\n",
      "set([u'ZZE'])\n",
      "set([u'I1B'])\n",
      "set([u'DND'])\n",
      "set([u'FEE'])\n",
      "set([u'FEB'])\n",
      "set([u'Q1C'])\n",
      "set([u'IJB'])\n",
      "set([u'VHB'])\n",
      "set([u'FBB'])\n",
      "set([u'GDB'])\n",
      "set([u'X0B'])\n",
      "set([u'TWA'])\n",
      "set([u'CIG'])\n",
      "set([u'USB'])\n",
      "set([u'U6A'])\n",
      "set([u'MSC'])\n",
      "set([u'IQB'])\n",
      "set([u'VSB'])\n",
      "set([u'PXC'])\n",
      "set([])\n",
      "set([u'VZA'])\n",
      "set([u'GVD'])\n",
      "set([u'ESB'])\n",
      "set([u'ULC'])\n",
      "set([u'ULE'])\n",
      "set([u'HED'])\n",
      "set([u'YGC'])\n",
      "set([u'YGB'])\n",
      "set([u'YGA'])\n",
      "set([u'I8C'])\n",
      "set([u'X0E'])\n",
      "set([u'HHC'])\n",
      "set([u'HHB'])\n",
      "set([u'KGC'])\n",
      "set([u'KGG'])\n",
      "set([u'EZB'])\n"
     ]
    }
   ],
   "source": [
    "SecondZeros = {}\n",
    "for i in Result_1:\n",
    "    if len(Result_1[i])==0:\n",
    "        SecondZeros[i] = FuncStatWrapper(i)\n",
    "\n",
    "for i in Result_1.keys():\n",
    "    if i not in SecondZeros:\n",
    "        for j in Result_1[i]:\n",
    "            if j in SecondZeros.keys():\n",
    "                SecondZeros[j].callers.add(j)\n",
    "\n",
    "for i in SecondZeros:\n",
    "    print SecondZeros[i].callers\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GiveAllLinken\n",
      "FYB\n",
      "AAYJ_0\n",
      "fxk_motherfxker_maphacker\n"
     ]
    }
   ],
   "source": [
    "for i in SecondZeros:\n",
    "    le = len(SecondZeros[i].callers)\n",
    "    if le == 0:\n",
    "        NoUseFunctions.append(i)\n",
    "        print i\n",
    "    elif le > 1:\n",
    "        MultipleCallerFunctions.append(i)\n",
    "    else:\n",
    "        pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3782\n",
      "set([u'XJD'])\n",
      "set([u'XJG'])\n",
      "set([u'BGE'])\n",
      "set([u'NAD'])\n",
      "set([u'CKB'])\n",
      "set([u'RYG'])\n",
      "set([])\n",
      "set([u'CPD'])\n",
      "set([u'O5F'])\n",
      "set([u'UQF'])\n",
      "set([u'PAD'])\n",
      "set([u'SID'])\n",
      "set([u'YUA'])\n",
      "set([u'WLA'])\n",
      "set([u'ZFA'])\n",
      "set([u'YUB'])\n",
      "set([u'MRF'])\n",
      "set([u'NYD'])\n",
      "set([u'NYE'])\n",
      "set([u'GEC'])\n",
      "set([])\n",
      "set([u'QPB'])\n",
      "set([u'MTF'])\n",
      "set([u'KYD'])\n",
      "set([u'OQF'])\n",
      "set([u'W9E'])\n",
      "set([u'XZA'])\n",
      "set([u'NQG'])\n",
      "set([u'B5G'])\n",
      "set([u'L0G'])\n",
      "set([u'PZG'])\n",
      "set([u'IOB'])\n",
      "set([u'WRF'])\n",
      "set([u'RNB'])\n",
      "set([u'CQH'])\n",
      "set([u'XIG'])\n",
      "set([u'XPC'])\n",
      "set([])\n",
      "set([u'RXC'])\n",
      "set([u'VPB'])\n",
      "set([u'HAD'])\n",
      "set([u'RXF'])\n",
      "set([u'TCF'])\n",
      "set([u'EHB'])\n",
      "set([u'QBG'])\n",
      "set([])\n",
      "set([])\n",
      "set([u'HRG'])\n",
      "set([u'FWC'])\n",
      "set([u'XAE'])\n",
      "set([u'B5D'])\n",
      "set([u'PQB'])\n",
      "set([u'PQD'])\n",
      "set([u'T7E'])\n",
      "set([u'E7B'])\n",
      "set([u'LXG'])\n",
      "set([u'RUB'])\n",
      "set([u'M5G'])\n",
      "set([u'WUG'])\n",
      "set([u'UYD'])\n",
      "set([u'CXF'])\n",
      "set([u'M5B'])\n",
      "set([u'SFG'])\n",
      "set([])\n",
      "set([])\n",
      "set([u'UZC'])\n",
      "set([u'Q2F'])\n",
      "set([u'EVB'])\n",
      "set([u'EVC'])\n",
      "set([u'ZWE'])\n",
      "set([u'BED'])\n",
      "set([u'O7B'])\n",
      "set([u'UAC'])\n",
      "set([u'MWF'])\n",
      "set([u'QGG'])\n",
      "set([u'ZDG'])\n",
      "set([u'BJH'])\n",
      "set([])\n",
      "set([u'RQF'])\n",
      "set([u'RTB'])\n",
      "set([u'EWB'])\n",
      "set([u'ROC'])\n",
      "set([u'F1F'])\n",
      "set([u'MZF'])\n",
      "set([u'A4H'])\n",
      "set([u'J9F'])\n",
      "set([u'NHD'])\n",
      "set([u'VKD'])\n",
      "set([u'YUG'])\n",
      "set([u'C4C'])\n",
      "set([u'JMB'])\n",
      "set([u'RQB'])\n",
      "set([u'JMF'])\n",
      "set([u'LLE'])\n",
      "set([u'LLD'])\n",
      "set([u'YKE'])\n",
      "set([])\n",
      "set([u'MHG'])\n",
      "set([u'H7D'])\n",
      "set([u'FBD'])\n",
      "set([u'JGD'])\n",
      "set([u'CJG'])\n",
      "set([u'T9C'])\n",
      "set([])\n",
      "set([u'KEG'])\n",
      "set([u'R1D'])\n",
      "set([u'XAF'])\n",
      "set([u'ZGA'])\n",
      "set([u'OPG'])\n",
      "set([u'ICD'])\n",
      "set([u'YCF'])\n",
      "set([u'W0B'])\n",
      "set([u'ODG'])\n",
      "set([u'V4C'])\n",
      "set([u'VOG'])\n",
      "set([u'UHB'])\n",
      "set([u'MGF'])\n",
      "set([u'XCE'])\n",
      "set([u'KIG'])\n",
      "set([u'ZRE'])\n",
      "set([u'NVG'])\n",
      "set([u'WWG'])\n",
      "set([u'JLF'])\n",
      "set([u'QHG'])\n",
      "set([u'J8F'])\n",
      "set([u'UWC'])\n",
      "set([u'HLE'])\n",
      "set([u'KKF'])\n",
      "set([u'ZWF'])\n",
      "set([u'MOD'])\n",
      "set([u'CIC'])\n",
      "set([])\n",
      "set([u'H9G'])\n",
      "set([u'GLF'])\n",
      "set([u'MUE'])\n",
      "set([u'O1F'])\n",
      "set([u'CTF'])\n",
      "set([u'JPB'])\n",
      "set([u'WYA'])\n",
      "set([u'W0E'])\n",
      "set([u'ISB'])\n",
      "set([u'D6B'])\n",
      "set([u'T4E'])\n",
      "set([u'JRF'])\n",
      "set([u'Q8B'])\n",
      "set([u'ECD'])\n",
      "set([])\n",
      "set([u'ZLC'])\n",
      "set([u'TYE'])\n",
      "set([u'XFA'])\n",
      "set([u'I1F'])\n",
      "set([u'G1B'])\n",
      "set([u'F7B'])\n",
      "set([u'RBB'])\n",
      "set([u'QTG'])\n",
      "set([u'PMG'])\n",
      "set([u'L4G'])\n",
      "set([u'K0G'])\n",
      "set([u'X7F'])\n",
      "set([u'IKG'])\n",
      "set([u'QMB'])\n",
      "set([u'ODE'])\n",
      "set([u'Y5G'])\n",
      "set([u'J7G'])\n",
      "set([u'F9B'])\n",
      "set([u'VTB'])\n",
      "set([u'Q1B'])\n",
      "set([u'JZF'])\n",
      "set([u'CLG'])\n",
      "set([u'SJC'])\n",
      "set([u'O6B'])\n",
      "set([u'N6F'])\n",
      "set([u'UNE'])\n",
      "set([u'LTE'])\n",
      "set([u'ZZF'])\n",
      "set([u'G4D'])\n",
      "set([u'YAA'])\n",
      "set([u'PDB'])\n",
      "set([u'DFC'])\n",
      "set([u'LRD'])\n",
      "set([u'AID'])\n",
      "set([u'OZG'])\n",
      "set([u'MEG'])\n",
      "set([u'LEC'])\n",
      "set([])\n",
      "set([u'ZEG'])\n",
      "set([u'LEG'])\n",
      "set([u'TDC'])\n",
      "set([u'CHG'])\n",
      "set([u'U1E'])\n",
      "set([u'RLB'])\n",
      "set([u'IFG'])\n",
      "set([u'E3B'])\n",
      "set([u'YYB'])\n",
      "set([u'WQE'])\n",
      "set([u'NBD'])\n",
      "set([u'J6G'])\n",
      "set([u'OED'])\n",
      "set([u'USG'])\n",
      "set([u'XHB'])\n",
      "set([u'Ld'])\n",
      "set([u'MYC'])\n",
      "set([u'TWE'])\n",
      "set([u'FQB'])\n",
      "set([])\n",
      "set([u'IBG'])\n",
      "set([u'ZSE'])\n",
      "set([u'QIB'])\n",
      "set([])\n",
      "set([u'LWC'])\n",
      "set([u'GPG'])\n",
      "set([u'U6D'])\n",
      "set([u'IQG'])\n",
      "set([u'BHD'])\n",
      "set([u'DAD'])\n",
      "set([u'PGG'])\n",
      "set([u'YFF'])\n",
      "set([u'GYB'])\n",
      "set([u'BIH'])\n",
      "set([u'D4C'])\n",
      "set([u'CAG'])\n",
      "set([u'EAB'])\n",
      "set([u'Y3D'])\n",
      "set([u'V9C'])\n",
      "set([u'AQG'])\n",
      "set([u'RKG'])\n",
      "set([u'M6D'])\n",
      "set([u'A8G'])\n",
      "set([u'RKC'])\n",
      "set([])\n",
      "set([u'B6B'])\n",
      "set([u'X4B'])\n",
      "set([u'FPG'])\n",
      "set([u'M0E'])\n",
      "set([u'MLG'])\n",
      "set([u'AMH'])\n",
      "set([u'Q7G'])\n",
      "set([])\n",
      "set([u'M7D'])\n",
      "set([u'FKG'])\n",
      "set([u'O0E'])\n",
      "set([u'WXF'])\n",
      "set([u'WCB'])\n",
      "set([u'DWF'])\n",
      "set([u'YPG'])\n",
      "set([u'LVC'])\n",
      "set([u'B7G'])\n",
      "set([u'RBG'])\n",
      "set([u'FXD'])\n",
      "set([u'VXB'])\n",
      "set([u'N4E'])\n",
      "set([u'TBC'])\n",
      "set([u'U7E'])\n",
      "set([])\n",
      "set([u'QSG'])\n",
      "set([])\n",
      "set([u'Z0E'])\n",
      "set([u'CFE'])\n",
      "set([u'X0F'])\n",
      "set([u'NRE'])\n",
      "set([u'WKF'])\n",
      "set([u'UDB'])\n",
      "set([u'W3F'])\n",
      "set([u'KGD'])\n",
      "set([u'QKB'])\n",
      "set([u'G0G'])\n",
      "set([u'BLD'])\n",
      "set([u'PNE'])\n",
      "set([u'DXB'])\n",
      "set([u'E1G'])\n",
      "set([u'CUB'])\n"
     ]
    }
   ],
   "source": [
    "Result_2 = {}\n",
    "for j in Result_1:\n",
    "    if j not in SecondZeros:\n",
    "        arr = [x for x in Result_1[j] if x not in SecondZeros]\n",
    "        Result_2[j] = arr\n",
    "print len(Result_2.keys())\n",
    "ThirdZeros = {}\n",
    "for i in Result_2:\n",
    "    if len(Result_2[i])==0:\n",
    "        ThirdZeros[i] = FuncStatWrapper(i)\n",
    "\n",
    "for i in Result_2.keys():\n",
    "    if i not in ThirdZeros:\n",
    "        for j in Result_2[i]:\n",
    "            if j in ThirdZeros.keys():\n",
    "                ThirdZeros[j].callers.add(j)\n",
    "\n",
    "for i in ThirdZeros:\n",
    "    print ThirdZeros[i].callers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "271\n"
     ]
    }
   ],
   "source": [
    "print len(ThirdZeros)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "341\n"
     ]
    }
   ],
   "source": [
    "# PublicFunctions = []\n",
    "FuncCallerStat = {}\n",
    "for i in Result:\n",
    "    FuncCallerStat[i] = FuncStatWrapper(i)\n",
    "    \n",
    "for i in Result:\n",
    "    for j in Result[i]:\n",
    "        FuncCallerStat[j].callers.add(i)\n",
    "\n",
    "PublicFunctions = [x for x in FuncCallerStat if len(FuncCallerStat[x].callers) > 5]\n",
    "print len(PublicFunctions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1217\n"
     ]
    }
   ],
   "source": [
    "# 统计所有的公共函数，标准是被Call的次数大于某个值，此外被公共函数call的函数也是公共函数\n",
    "# 现在公共函数的标准是被call两次及以上\n",
    "PublicFunctions = [x for x in FuncCallerStat if len(FuncCallerStat[x].callers) > 1]\n",
    "print len(PublicFunctions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    }
   ],
   "source": [
    "# 从剩余的函数中统计公共函数\n",
    "ExtraPublicFunctions = []\n",
    "for i in FuncCallerStat:\n",
    "    if i not in PublicFunctions:\n",
    "        for j in FuncCallerStat[i].callers:\n",
    "            if j in PublicFunctions:\n",
    "                ExtraPublicFunctions.append(i)\n",
    "                PublicFunctions.append(i)\n",
    "print len(ExtraPublicFunctions)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "245\n"
     ]
    }
   ],
   "source": [
    "print len(Result) - len(PublicFunctions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "rrrr = {\"Main\":[x for x in Result if x not in PublicFunctions], \"Public\":PublicFunctions}\n",
    "import json\n",
    "open(\"main-public.json\",\"w\").write(json.dumps(rrrr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "class linode:\n",
    "    def __init__(self, name):\n",
    "        self._name = name\n",
    "#         self._prev = None\n",
    "        self._next = None\n",
    "#     def add_prev(self, node):\n",
    "#         self._prev = node\n",
    "    def add_next(self, node):\n",
    "        self._next = node\n",
    "        \n",
    "class line:\n",
    "    def __init__(self, node):\n",
    "        self._names = [node._name]\n",
    "        self._head = node\n",
    "        self._tail = node\n",
    "    def expand(self, node, pos = \"head\"):\n",
    "        if pos == \"head\":\n",
    "            node.add_next(self._head)\n",
    "            self._head = node\n",
    "        else:\n",
    "            self._tail.add_next(node)\n",
    "            self._tail = node"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "MainSet = set([x for x in Result if x not in PublicFunctions])\n",
    "\n",
    "Lines = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "There is 0 funcs left!\n"
     ]
    }
   ],
   "source": [
    "print \"There is %d funcs left!\" % len(MainSet)\n",
    "while len(MainSet) > 0:\n",
    "    aname = list(MainSet)[0]\n",
    "    MainSet.remove(aname)\n",
    "    theline = line(linode(aname))\n",
    "    changeflag = 1\n",
    "    while changeflag > 0 :\n",
    "        prev = [x for x in FuncCallerStat[theline._head._name].callers if x in MainSet]\n",
    "        if len(prev) > 0:\n",
    "            theline.expand(linode(prev[0]), \"head\")\n",
    "            MainSet.remove(prev[0])\n",
    "        _next = [x for x in Result[theline._head._name] if x in MainSet]\n",
    "        if len(_next) > 0:\n",
    "            theline.expand(linode(_next[0]), \"tail\")\n",
    "            MainSet.remove(_next[0])\n",
    "        if len(prev) == 0 and len(_next) == 0:\n",
    "            changeflag = 0\n",
    "    Lines.append(theline)\n",
    "# n = theline._head\n",
    "# while n:\n",
    "#     print \"%s =>\" % n._name\n",
    "#     n = n._next\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def printline(line):\n",
    "    n = line._head\n",
    "    string = \"\"\n",
    "    while n:\n",
    "        string += \"%s =>\" % n._name\n",
    "        n = n._next\n",
    "    print string[:-3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TestUnitOut\n",
      "AAAS\n",
      "AAAR\n",
      "W7E =>WDA =>W8E =>W6E\n",
      "RefreshAllUnitSpeed =>DAH\n",
      "A02A_DefenceFunc\n",
      "ChristmasDay =>CLG =>CKG =>CMG\n",
      "CheckHeroifComputer =>CPG =>NJE =>HDG\n",
      "DKF\n",
      "SecretModel\n",
      "GHF\n",
      "GKG =>GHG =>GJG\n",
      "A0HE_FullFX2_Func\n",
      "LWv =>SID\n",
      "AAAI\n",
      "rwe =>B7F =>B5F =>B2F =>BWF =>B6F\n",
      "AAAM\n",
      "A1E6_B =>VYB =>VZB =>VXB\n",
      "fxk_motherfxker_maphacker =>ZQA =>ZRA\n",
      "acaub =>RCG =>RAG =>RBG\n",
      "HSF =>HJF\n",
      "G0F =>G9F =>G5F =>G6F =>GYF =>G8F =>G2F\n",
      "CM_Mode_Active =>S8C =>S6C =>S4C =>SUC\n",
      "OHD\n",
      "SplitArrow\n",
      "NND\n",
      "ttt000tttt\n",
      "NotAllyHeroInRange\n",
      "BalancedGarrison =>HVC\n",
      "a0ntc\n",
      "testWaves =>NBC\n",
      "StrucDefOnLivingHeros =>HKC =>HIC =>HJC\n",
      "GVF =>GMF =>GLF =>GUF =>GTF =>GKF\n",
      "LongName_uM\n",
      "A1E9_ABA\n",
      "RKB\n",
      "YOC =>TPA\n",
      "MVv =>VIC\n",
      "A0DZ\n",
      "HIF =>HAF =>HBF =>HEF =>HHF =>HGF =>HFF\n",
      "AA9C_old =>YHG\n",
      "GIG\n",
      "AAB0\n",
      "ShowItemInfo =>XSA\n",
      "SetStrucBonusDefence\n",
      "DJF\n",
      "BYF\n",
      "A0OJD\n",
      "BRF =>BNF\n",
      "QRD =>QQD =>QND\n",
      "S5C\n",
      "HasBuildTimerOfAKSS\n",
      "kill1hero\n",
      "YGG =>YFG =>YEG =>ATF\n",
      "fxkSheBang\n",
      "AIplA\n",
      "SQB\n",
      "AC3BB =>QYG\n",
      "NotAllyNotImmune\n",
      "testStop\n",
      "RemoveB0BI\n",
      "DebugAbilityIcon =>YJA\n",
      "AAXX_A\n",
      "P8B\n",
      "FLG\n",
      "NOF =>NNF =>NMF\n",
      "XEE =>XDE\n",
      "CheckI81J\n",
      "TKB\n",
      "LongName_un\n",
      "ROD\n",
      "YZA\n",
      "AddBossLife\n",
      "GFG =>GEG =>GDG\n",
      "a0nt\n",
      "NeutralsGet100Crit\n",
      "MotherFuckMapHackers\n",
      "TCB\n",
      "UXE =>UVE =>UWE\n",
      "CheckAbilityPercent\n",
      "BVF =>BSF\n",
      "CountRectDests =>QZB =>QYB =>QXB =>QWB\n",
      "BDF =>A9F\n",
      "LongName_ji\n",
      "LongName_jh\n",
      "CJB\n",
      "GRF\n",
      "AANN\n",
      "a022\n",
      "B017_Stop\n",
      "B3F\n",
      "A1P6\n",
      "ozv\n",
      "config =>InitCustomTeams\n",
      "GZF\n",
      "S7E\n",
      "XGE\n",
      "qbv =>W8D\n",
      "CallRefreshRandomRunes\n",
      "AAYJ_0\n",
      "A0Q5A\n",
      "RemoveAvul_A14OB\n",
      "YQF\n",
      "Q0G\n",
      "GetDownStruc =>HYC\n",
      "UnitScaleNum\n",
      "TestHashLoadRead\n",
      "CGD\n",
      "KillAllNeutrals\n",
      "z_AA9D_old\n",
      "R2G\n",
      "YCE\n",
      "AUC\n",
      "AC47A\n",
      "ShowMinimapIcon\n",
      "BBFunctionA\n",
      "AIpg_A\n",
      "PFB\n",
      "S1B\n",
      "a19za =>QFG\n",
      "B1F\n",
      "StartTestDropTimer\n",
      "TDB\n",
      "isOrderEvent\n",
      "ReviveHeroNew\n",
      "TESTITEMDROP\n",
      "isNeedInit =>MKG\n",
      "B7H\n",
      "I8A\n",
      "YND\n",
      "GQF\n",
      "GiveAllLinken\n",
      "R2B =>RZB\n",
      "AddAvul_A14OB\n",
      "W7D\n",
      "ddmgFunc\n",
      "X9G\n",
      "lKv\n",
      "PauseUnitAnd10WLife\n",
      "FYB\n",
      "FuckMapHackers\n",
      "LCD\n",
      "Active_UL_Mode\n",
      "RPB\n",
      "V9D\n",
      "JHv\n",
      "GAG\n",
      "Vbe\n",
      "A0BR\n",
      "A06A\n",
      "FKB\n",
      "V0D\n",
      "Z1a2\n",
      "AA55_Effect\n",
      "xdv\n",
      "V8D\n",
      "TFB\n",
      "PWD\n",
      "pRv\n",
      "AEbl_Shadow_Move\n",
      "AA5LB\n"
     ]
    }
   ],
   "source": [
    "for i in Lines:\n",
    "    printline(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set([u'G8D', u'G6D', u'YZB', u'LXC', u'GSD', u'GND'])\n"
     ]
    }
   ],
   "source": [
    "print FuncCallerStat[\"main\"].callers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set([u'SXG'])\n"
     ]
    }
   ],
   "source": [
    "print FuncCallerStat[\"G8D\"].callers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set([u'A5H'])\n"
     ]
    }
   ],
   "source": [
    "print FuncCallerStat[\"SXG\"].callers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set([u'main'])\n"
     ]
    }
   ],
   "source": [
    "print FuncCallerStat[\"A5H\"].callers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "FuncCallerStat[\"main\"].callers = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "PublicFunctions.append(\"main\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    }
   ],
   "source": [
    "NotOrphanFunc = [x for x in Result[\"main\"] if x in MainSet]\n",
    "print NotOrphanFunc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[u'CKE', u'SIB', u'G5G', u'PIC', u'TAC', u'RIG', u'tb', u'SPE', u'URB', u'DJC', u'NXC', u'A7H', u'WZE', u'DBH', u'AHD', u'lW', u'DBE', u'G2C', u'MAG', u'FFE', u'EMB', u'CMC', u'RGE', u'AME', u'ROE', u'SCC', u'PKB', u'YZB', u'Z5A', u'D0C', u'GED', u'UVB', u'MNG', u'DLC', u'FOG', u'B3H', u'GOC', u'BLE', u'C7C', u'EFF', u'BLH', u'IVE', u'G4C', u'HTC', u'YPC', u'A5H', u'GZC', u'E5B', u'DDH', u'AVH', u'UWB', u'ING', u'GRC', u'SUE', u'L3C', u'VUA', u'YPE', u'ZJB', u'ATH', u'ETC', u'ZRF', u'UMB', u'IDC', u'WHA', u'G1C', u'RMC', u'QTB', u'Y5A', u'GTC', u'IME', u'FEC', u'ELC', u'RDE', u'U9B', u'DFH', u'D9C', u'JRC', u'LEE', u'LEF', u'GNC', u'ALF', u'TDA', u'ITE', u'FBE', u'ORD', u'WQA', u'USE', u'IBC', u'FHC', u'To', u'DPC', u'EIG', u'RCE', u'GYC', u'PPE', u'F5F', u'G3C', u'FAC', u'FPC', u'DHH', u'GVC', u'K8C', u'ZKB', u'TNE', u'TND', u'TNG', u'TNF', u'TNA', u'TNC', u'TNB', u'C9H', u'AJF', u'C1H', u'EXNetGetCount', u'NKE', u'F9F', u'TFA', u'JPG', u'ARG', u'PNB', u'NCF']\n"
     ]
    }
   ],
   "source": [
    "print Result[\"main\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
